

class Solution(object):
    def majorityElement(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        # if len(nums) == 1:
        #     print(nums[0])
        # numDic = {}
        # for i in nums:
        #     if numDic.has_key(i):
        #         numDic[i] += 1
        #         if numDic.get(i) >= (len(nums)+1)/2:
        #             print(i)
        #         else:
        #             numDic[i] = 1

        # 优化
        # for i in nums:
        #     # print(nums.count(i))
        #     if nums.count(i) > len(nums)/2:
        #         print(nums.count(i))
        #         break

        # 优化
        print(sorted(nums)[len(nums)//2])


if __name__ == '__main__':
    sol = Solution()
    sol.majorityElement([3, 2, 3])
